<?php
// application/forms/Article.php

class ads_Form_ContactMail extends Zend_Form
{

    protected $_noDecorator = array(
        'ViewHelper', 
        'Errors'
    );

    public function cluBuild($data = null)
    {
        // set the method for the display form to POST
        $this->setAttrib('id', 'contact_mail');
        $this->setMethod('POST');
        $this->setAction($data['action_url']);
	        
        $urlValidator = new Zend_Validate_Regex('/^[A-Z0-9_\s\-\/\%]*$/i'); //alpha, num, space, -, _
        $myValidator = new Zend_Validate_Regex('/^[A-Z0-9_\s\-]*$/i'); //alpha, num, space, -, _
        $myValidator->setMessage(__("Only alphanum, spaces, -, _ allowed"), Zend_Validate_Regex::NOT_MATCH);
        $this->addElementPrefixPath('Clu_Filter', 'Clu/Filter/', 'filter');
                
        //add block name
        
        $title = new Zend_Form_Element_Text('title', 
                         array('disableLoadDefaultDecorators' => true,
                               'required'   => true,             
                               'class' => 'inputText'));
        
        $title->addDecorators($this->_noDecorator)
              ->addValidator($myValidator);
        $this->addElement($title);
        
        $name = new Zend_Form_Element_Text('name', 
                         array('disableLoadDefaultDecorators' => true,
                               'required'   => true,             
                               'class' => 'inputText'));
        
        $name->addDecorators($this->_noDecorator)
              ->addValidator($myValidator);
        $this->addElement($name);
        
        $address = new Zend_Form_Element_Text('address', 
                 array('disableLoadDefaultDecorators' => true,
                       'required'   => true,             
                       'class' => 'inputText'));

        $address->addDecorators($this->_noDecorator)
              ->addValidator($myValidator);
        $this->addElement($address);
        
        $email = new Zend_Form_Element_Text('email', 
                 array('disableLoadDefaultDecorators' => true,
                       'class' => 'inputText'));
		$validatorEmail = new Zend_Validate_EmailAddress();
        $validatorEmail->setMessages(
            array(
                Zend_Validate_EmailAddress::INVALID            => t(743),
                Zend_Validate_EmailAddress::INVALID_HOSTNAME   => t(744),
        ));

        $email->addDecorators($this->_noDecorator)
              ->addValidator($validatorEmail);
        $this->addElement($email);
        
        //add description $user
        $html = new Clu_Form_Element_FckEditor('text', array(
        		'fckOptions' => array (
        						'Height' => 350,
        						'Width'  => 400,
        						'ToolbarSet' => 'Block'
        					)
       			 )
        );
        $html->setLabel(__('Text'));

		
        $this->addElement($html);
        
		//add the submit button
        $submit = new Zend_Form_Element_Submit('contact_submit', array('disableLoadDefaultDecorators' => true, 
                                                               'label' => __(t(172)) ));
        $submit->addDecorators($this->_noDecorator);
        $this->addElement($submit);
    }
    
    public function populateForm($data)
    {
		$this->populate($data);
    }
}
